// pages/finddetail/index.js
Page({
  /**
   * 页面的初始数据
   */
  data: {
    DetailList: [],
    userInfo: [{
      icon: "/pages/images/xinxi.png",
      title: "年级",
      littleTitle: "访客年级",
      click: "class"
    }, {
      icon: "/pages/images/xinxi.png",
      title: "专业",
      littleTitle: "访客专业",
      click: "academy"
    }, {
      icon: "/pages/images/xinxi.png",
      title: "联系电话",
      littleTitle: "电话",
      click: "tel"
    }, {
      icon: "/pages/images/xinxi.png",
      title: "QQ",
      littleTitle: "访客QQ",
      click: "qq"
    }],
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(e) {
    //e.id为要请求的id
    //请求（赞未写）
    //console.log(e.id);
    var that = this;
    const db = wx.cloud.database().collection("List");
    db.where({
      _id: e.id
    }).get({
      success: function (res) {
        // res.data 是包含以上定义的两条记录的数组
        const templist = res.data;
        //console.log(templist[0]._id);
        that.setData({
          DetailList: templist[0],
        })
        //console.log(templist[0]._id);
          const db2 = wx.cloud.database().collection("infList");
          db2.where({
            _openid:templist[0]._openid,
          }).get({
            success(res) {
              var temp = that.data.userInfo;
              temp[0].littleTitle = res.data[0].grade;
              temp[1].littleTitle = res.data[0].cs;
              temp[2].littleTitle = res.data[0].phone;
              temp[3].littleTitle = res.data[0].QQ;
              that.setData({
                userInfo:temp,
              })
              console.log(that.data.userInfo);
            }
          })
      }
    })
  },
})